#include <bits/stdc++.h>
#define re register
#define int long long
#define chmax(a,b) (a = max(a,b))

using namespace std;

const int N = 5010;
const int inf = (int)(1e18) + 10;
int cid,n,k;
int t[N],arr[N],brr[N];
int r,dp[2][N];

inline int read(){
    int r = 0,w = 1;
    char c = getchar();
    while (c < '0' || c > '9'){
        if (c == '-') w = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9'){
        r = (r << 1) + (r << 3) + (c ^ 48);
        c = getchar();
    }
    return r * w;
}

inline void solve(){
    int ans = -inf,m = 0; r = 0;
    n = read(),k = read(); arr[n + 1] = inf;
    fill(t + 1,t + n + 1,0);
    for (re int i = 2;i <= n;i++) chmax(m,arr[i] = read());
    for (re int i = 1;i <= k;i++) brr[i] = read();
    for (re int i = 1;i + k - 1 <= n;i++){
        for (re int j = i;j <= i + k - 1;j++) t[j] += brr[j - i + 1];
    }
    for (re int j = 0;j <= arr[2];j++) dp[0][j] = j * t[1];
    for (re int j = arr[2] + 1;j <= m;j++) dp[0][j] = -inf;
    for (re int i = 2;i <= n;i++){
        r ^= 1;
        for (re int j = 0;j <= m;j++){
            dp[r][j] = -inf;
            if (j <= min(arr[i],arr[i + 1])){
                for (re int k = 0;k <= arr[i] - j;k++) chmax(dp[r][j],dp[r ^ 1][k] + j * t[i]);
            }
        }
    }
    // for (re int i = 1;i <= n;i++){
    //     for (re int j = 0;j <= 5;j++){
    //         if (dp[i][j] > 0) cerr << i << " " << j << " " << dp[i][j] << " !!!\n";
    //     }
    // }
    for (re int j = 0;j <= m;j++) chmax(ans,dp[r][j]);
    printf("%lld\n",ans);
}

signed main(){
    freopen("festival.in","r",stdin);
    freopen("festival.out","w",stdout);
    int T; cid = read(),T = read();
    while (T--) solve();
    return 0;
}

/*
0 1
4 2
5 4 2
2 1

0 1
7 4
4 8 6 7 8 3
3 5 1 2

0 1
8 1
1 1 1 1 1 1 1 
4 
*/